'use strict';

const Controller = require('egg').Controller;

class PayType extends Controller {
  async list () {
    const { ctx, app } = this
    let user_id
    try {
      const token = ctx.request.header.authorization

      const decode = await app.jwt.verify(token, app.config.jwt.secret)
      if (!decode) return
      user_id = decode.id
      const result = await ctx.service.paytype.list(
        user_id
      )
      ctx.body = {
        code: 200,
        msg: '请求成功',
        data: result
      }
    } catch (error) {
      ctx.body = {
        code: 500,
        msg: '请求失败',
        data: null
      }
    }
  }
}

module.exports = PayType;
